<!doctype html>
 <html>
 	<head>
 		<title>文章内容开始</title>
 		<meta name="renderer" content="webkit">
 		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
 		<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no" />
 		<meta charset="utf-8">
 		<script src="/static/common/js/jquery.min.js"></script>
 	<body>
 		<button id="btn">文章内容开始</button>
		<div>进度：<span class="por"></span></div>
 		<div id="sd"></div>
 <h2></h2>
 		<script>
 			//写入书
 			$("#btn").click(function() {
 				writeBooks(0)
 			})

 			function writeBooks(j) {
 				new Promise(function(resolve, reject) {
 					$.ajax({
 						url: '{:url("/index/xiaoshuo.index/writeArchives")}',
 						type: 'get',
 						data: 'start=' + j,
 						success: function(res) {

 							resolve(res)
 						}
 					})
 				}).then(res => {
 					let data = res.data[0];
					$(".por").html(res.count)
					console.log(res)
					if(res.code==-2){
						var html = '<h2>' + res.msg + '</h2>'
						$("#sd").append(html)
					}else{
						var html = '<h2>' + res.msg + '</h2>'
						$("h2:first").before(html)
						let lenght=$("h2").length
						console.log(lenght)
						if(lenght>50){
							 $('h2:last').remove()
						}
						
						 writeBooks(res.count)
					}
 					

 				})
 			}

 			function sendurl(base_url,id,nums) {
 				console.log(nums)
 				new Promise(function(resolve, reject) {
 					$.ajax({
 						url: '{:url("/index/xiaoshuo.index/writeBooks")}',
 						type: 'post',
 						data: {
							 'url':base_url,
							 'id':id
						},
 						success: function(res) {

 							resolve(res)
 						}
 					}).then(res => {
 						console.log(res)
 						var html = '<h2>' + res.msg + '</h2>'
 						$("#sd").append(html)
 					//	writeBooks(nums)
 					})
 				})
 			}

 		 
 		</script>

 	</body>
